#ifndef TOP_QUERIES_PROCESSOR_H
#define TOP_QUERIES_PROCESSOR_H


#include <map>
#include <deque>
#include <string>
#include <Packet/packet.h>
#include "processor.h"
#include <time.h>

class TopQueriesProcessor : public Processor
{
	public:
    enum OutputFormat{ JIT = 0, PV_ALL, PV_2_LEVEL }; //JIT no longer supported

		TopQueriesProcessor();
		virtual ~TopQueriesProcessor();

		void setInterval( const uint32_t &interval );

		uint32_t interval( ) const;

		void setOutfile( const std::string &outfile );

		std::string outfile( ) const;

		void processDNSPacket( const Packet &p );

		void printResults() const;

		void writeResults( );

		void setMinFrequency(const uint32_t &frequency );

		uint32_t minFrequency() const;

	private:
	  
		void writeJitFile(); //No longer supported format for jit
		void writePvAll(); //all info
		void writePv2Level(); // only 2nd level domain info
		std::map< std::string, std::deque<uint32_t> > filter( const std::map< std::string, std::deque< uint32_t> > &rawdata ) const;
		std::map< std::string, std::deque<uint32_t> > queryCounts_;
		std::map< std::string, std::map<std::string, uint32_t> > queryClients_; //who was requesting the data and how many times
		uint32_t interval_;
		uint32_t intervalCount_;
		std::string outfile_;
		time_t startTime_; //of the capture (pcap or device)
		bool initializedStartTime_;
		OutputFormat outputFormat_;
		uint32_t minFrequency_;
};

#endif
